#

| Chapter 25 Showing What's in a File |

## 25.18 Watching Several Files Grow

Now here's a useful tool: suppose you want to monitor several files at once. Administrators, for example, might want to keep track of several log files, such as /usr/adm/messages, /usr/adm/lpd-errs, UUCP error files, etc.

xtail | The xtail program comes in useful for keeping an eye on several administrative log files at once. But it also comes in useful for non-administrators. It's sort of a tail -f for several files as once.

For example, suppose you want to perform several greps through many files, saving the output in different files. You can then monitor the files using xtail. For example:

>     % grep Berkeley ch?? > Berkeley.grep &
>     % grep BSD ch?? > BSD.grep &
>     % grep "System V" ch?? > SystemV.grep &
>     % grep SysV ch?? > SysV.grep &
>     % xtail Berkeley.grep BSD.grep SystemV.grep SysV.grep

When new text appears in the files called with xtail, it also appears on the screen:

>     *** SysV.grep ***
>     ch01:using a SysV-based UNIX system, you must

>     *** Berkeley.grep ***
>     ch01:at the University of California at Berkeley, where

>     *** BSD.grep ***
>     ch03:prefer BSD UNIX systems because they are less likely to
>     ch04:who use a BSD-based UNIX systems must run the

>     *** SysV.grep ***
>     ch04:is a SysV derivative sold by Acme Products Inc.

(When text is written to a new file, the filename is printed surrounded by `***`.)

If you press your interrupt key (5.9) (usually CTRL-c or DEL), xtail will tell you which files have been modified most recently:

>     [CTRL-c]
>     *** recently changed files ***
>        1   4-Nov-92 18:21:12  BSD.grep
>        2   4-Nov-92 18:19:52  Berkeley.grep
>        3   4-Nov-92 17:42:45  SysV.grep

To exit xtail, you must send the QUIT signal (usually CTRL-\, control-backslash).

If an argument given to xtail is a directory name and not a filename, then xtail monitors all files in that directory. For administrators, this comes in very useful for monitoring the UUCP (1.33) log files in all the subdirectories of /usr/spool/uucp/.Log:

>     % xtail /usr/spool/uucp/.Log/*

- LM

25.17 An Alias in Case You Don't Have tail |  | 25.19 Reverse Lines in Long Files with flip